<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
      <!-- <el-form-item label="项目编码" prop="projectNo">
        <el-input v-model="queryParams.projectNo" placeholder="请输入项目编码" clearable @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <el-form-item label="项目名称" prop="projectName">
        <el-input v-model="queryParams.projectName" placeholder="请输入项目名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="运行状态" prop="operationStatus">
        <el-select clearable @keyup.enter.native="handleQuery" v-model="queryParams.operationStatus"
          placeholder="请选择运行状态">
          <el-option label="未启动" value="未启动" />
          <el-option label="进行中" value="进行中" />
          <el-option label="停滞" value="停滞" />
          <el-option label="已完工" value="已完工" />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="地理id" prop="addressId">
        <el-input v-model="queryParams.addressId" placeholder="请输入地理id" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="项目地址" prop="projectAddress">
        <el-input v-model="queryParams.projectAddress" placeholder="请输入项目地址" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="项目经理" prop="projectManager">
        <el-input v-model="queryParams.projectManager" placeholder="请输入项目经理" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="备注" prop="remarks">
        <el-input v-model="queryParams.remarks" placeholder="请输入备注" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="工程性质" prop="engineeringNature">
        <el-input v-model="queryParams.engineeringNature" placeholder="请输入工程性质" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="地层信息" prop="strataInformation">
        <el-input v-model="queryParams.strataInformation" placeholder="请输入地层信息" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="地下水" prop="groundwater">
        <el-input v-model="queryParams.groundwater" placeholder="请输入地下水" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="地形、地貌特征" prop="topographyFeature">
        <el-input v-model="queryParams.topographyFeature" placeholder="请输入地形、地貌特征" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="地震信息" prop="seismicInformation">
        <el-input v-model="queryParams.seismicInformation" placeholder="请输入地震信息" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="不良地质" prop="geologicalHazards">
        <el-input v-model="queryParams.geologicalHazards" placeholder="请输入不良地质" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="腐蚀性评价" prop="corrosionEvaluation">
        <el-input v-model="queryParams.corrosionEvaluation" placeholder="请输入腐蚀性评价" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="开工时间" prop="startTime">
        <el-date-picker clearable v-model="queryParams.startTime" type="date" value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="请选择开工时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="项目产值(万元)" prop="outputValue">
        <el-input v-model="queryParams.outputValue" placeholder="请输入项目产值(万元)" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="省份id" prop="provinceId">
        <el-input v-model="queryParams.provinceId" placeholder="请输入省份id" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="省份名称" prop="provinceName">
        <el-input v-model="queryParams.provinceName" placeholder="请输入省份名称" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="城市名称" prop="cityName">
        <el-input v-model="queryParams.cityName" placeholder="请输入城市名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="区名称" prop="regionName">
        <el-input v-model="queryParams.regionName" placeholder="请输入区名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="设备序列号" prop="deviceSerial">
        <el-input v-model="queryParams.deviceSerial" placeholder="请输入设备序列号" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="经度" prop="longitude">
        <el-input v-model="queryParams.longitude" placeholder="请输入经度" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="纬度" prop="latitude">
        <el-input v-model="queryParams.latitude" placeholder="请输入纬度" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="创建人id" prop="creatorId">
        <el-input v-model="queryParams.creatorId" placeholder="请输入创建人id" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="创建人姓名" prop="creatorName">
        <el-input v-model="queryParams.creatorName" placeholder="请输入创建人姓名" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="最后修改人id" prop="lastUpdaterId">
        <el-input v-model="queryParams.lastUpdaterId" placeholder="请输入最后修改人id" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="最后修改人姓名" prop="lastUpdaterName">
        <el-input v-model="queryParams.lastUpdaterName" placeholder="请输入最后修改人姓名" clearable
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="最后修改时间" prop="lastUpdateTime">
        <el-date-picker clearable v-model="queryParams.lastUpdateTime" type="date" value-format="yyyy-MM-dd HH:mm:ss"
          placeholder="请选择最后修改时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="计划完成桩数" prop="planPiles">
        <el-input v-model="queryParams.planPiles" placeholder="请输入计划完成桩数" clearable @keyup.enter.native="handleQuery" />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['pile:project:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['pile:project:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['pile:project:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['pile:project:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="projectList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="主键" align="center" prop="id" /> -->
      <!-- <el-table-column label="项目编码" align="center" prop="projectNo" /> -->
      <el-table-column label="项目名称" align="center" prop="projectName">
        <template slot-scope="scope">
          <span class="project-name">{{ scope.row.projectName }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="地理id" align="center" prop="addressId" /> -->
      <el-table-column label="项目地址" align="center" prop="projectAddress" />
      <el-table-column label="项目经理" align="center" prop="projectManager" />
      <el-table-column label="项目类型" align="center" prop="projectType">
        <template slot-scope="scope">
          <span :class="getProjectTypeClass(scope.row.projectType)">{{ scope.row.projectType }}</span>
        </template>
      </el-table-column>
      <el-table-column label="工程类型" align="center" prop="engineeringType" />
      <el-table-column label="运行状态" align="center" prop="operationStatus">
        <template slot-scope="scope">
          <span :class="getOperationStatusClass(scope.row.operationStatus)">{{ scope.row.operationStatus }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="备注" align="center" prop="remarks" /> -->
      <!-- <el-table-column label="工程性质" align="center" prop="engineeringNature" /> -->
      <!-- <el-table-column label="地层信息" align="center" prop="strataInformation" /> -->
      <!-- <el-table-column label="地下水" align="center" prop="groundwater" /> -->
      <!-- <el-table-column label="地形、地貌特征" align="center" prop="topographyFeature" /> -->
      <!-- <el-table-column label="地震信息" align="center" prop="seismicInformation" /> -->
      <!-- <el-table-column label="不良地质" align="center" prop="geologicalHazards" /> -->
      <!-- <el-table-column label="腐蚀性评价" align="center" prop="corrosionEvaluation" /> -->
      <el-table-column label="开工时间" align="center" prop="startTime" width="180">
        <template slot-scope="scope">
          <span v-if="scope.row.startTime" class="start-time">{{ parseTime(scope.row.startTime) }}</span>
          <span v-else class="empty-time">—</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="项目产值(万元)" align="center" prop="outputValue" />
      <el-table-column label="省份id" align="center" prop="provinceId" />
      <el-table-column label="省份名称" align="center" prop="provinceName" />
      <el-table-column label="城市名称" align="center" prop="cityName" />
      <el-table-column label="区名称" align="center" prop="regionName" />
      <el-table-column label="设备序列号" align="center" prop="deviceSerial" />
      <el-table-column label="经度" align="center" prop="longitude" />
      <el-table-column label="纬度" align="center" prop="latitude" /> -->

      <!-- <el-table-column label="创建人id" align="center" prop="creatorId" /> -->
      <!-- <el-table-column label="创建人姓名" align="center" prop="creatorName" /> -->
      <!-- <el-table-column label="最后修改人id" align="center" prop="lastUpdaterId" /> -->
      <!-- <el-table-column label="最后修改人姓名" align="center" prop="lastUpdaterName" /> -->
      <!-- <el-table-column label="最后修改时间" align="center" prop="lastUpdateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastUpdateTime) }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="计划完成桩数" align="center" prop="planPiles" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleDetail(scope.row)">详情</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['pile:project:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['pile:project:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改项目对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="项目编码" prop="projectNo">
          <el-input v-model="form.projectNo" placeholder="请输入项目编码" />
        </el-form-item>
        <el-form-item label="项目名称" prop="projectName">
          <el-input v-model="form.projectName" placeholder="请输入项目名称" />
        </el-form-item>
        <el-form-item label="地理id" prop="addressId">
          <el-input v-model="form.addressId" placeholder="请输入地理id" />
        </el-form-item>
        <el-form-item label="项目地址" prop="projectAddress">
          <el-input v-model="form.projectAddress" placeholder="请输入项目地址" />
        </el-form-item>
        <el-form-item label="项目经理" prop="projectManager">
          <el-input v-model="form.projectManager" placeholder="请输入项目经理" />
        </el-form-item>
        <el-form-item label="备注" prop="remarks">
          <el-input v-model="form.remarks" placeholder="请输入备注" />
        </el-form-item>
        <el-form-item label="工程性质" prop="engineeringNature">
          <el-input v-model="form.engineeringNature" placeholder="请输入工程性质" />
        </el-form-item>
        <el-form-item label="地层信息" prop="strataInformation">
          <el-input v-model="form.strataInformation" placeholder="请输入地层信息" />
        </el-form-item>
        <el-form-item label="地下水" prop="groundwater">
          <el-input v-model="form.groundwater" placeholder="请输入地下水" />
        </el-form-item>
        <el-form-item label="地形、地貌特征" prop="topographyFeature">
          <el-input v-model="form.topographyFeature" placeholder="请输入地形、地貌特征" />
        </el-form-item>
        <el-form-item label="地震信息" prop="seismicInformation">
          <el-input v-model="form.seismicInformation" placeholder="请输入地震信息" />
        </el-form-item>
        <el-form-item label="不良地质" prop="geologicalHazards">
          <el-input v-model="form.geologicalHazards" placeholder="请输入不良地质" />
        </el-form-item>
        <el-form-item label="腐蚀性评价" prop="corrosionEvaluation">
          <el-input v-model="form.corrosionEvaluation" placeholder="请输入腐蚀性评价" />
        </el-form-item>
        <el-form-item label="开工时间" prop="startTime">
          <el-date-picker clearable v-model="form.startTime" type="date" value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择开工时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="项目产值(万元)" prop="outputValue">
          <el-input v-model="form.outputValue" placeholder="请输入项目产值(万元)" />
        </el-form-item>
        <el-form-item label="省份id" prop="provinceId">
          <el-input v-model="form.provinceId" placeholder="请输入省份id" />
        </el-form-item>
        <el-form-item label="省份名称" prop="provinceName">
          <el-input v-model="form.provinceName" placeholder="请输入省份名称" />
        </el-form-item>
        <el-form-item label="城市名称" prop="cityName">
          <el-input v-model="form.cityName" placeholder="请输入城市名称" />
        </el-form-item>
        <el-form-item label="区名称" prop="regionName">
          <el-input v-model="form.regionName" placeholder="请输入区名称" />
        </el-form-item>
        <el-form-item label="设备序列号" prop="deviceSerial">
          <el-input v-model="form.deviceSerial" placeholder="请输入设备序列号" />
        </el-form-item>
        <el-form-item label="经度" prop="longitude">
          <el-input v-model="form.longitude" placeholder="请输入经度" />
        </el-form-item>
        <el-form-item label="纬度" prop="latitude">
          <el-input v-model="form.latitude" placeholder="请输入纬度" />
        </el-form-item>
        <el-form-item label="创建人id" prop="creatorId">
          <el-input v-model="form.creatorId" placeholder="请输入创建人id" />
        </el-form-item>
        <el-form-item label="创建人姓名" prop="creatorName">
          <el-input v-model="form.creatorName" placeholder="请输入创建人姓名" />
        </el-form-item>
        <el-form-item label="最后修改人id" prop="lastUpdaterId">
          <el-input v-model="form.lastUpdaterId" placeholder="请输入最后修改人id" />
        </el-form-item>
        <el-form-item label="最后修改人姓名" prop="lastUpdaterName">
          <el-input v-model="form.lastUpdaterName" placeholder="请输入最后修改人姓名" />
        </el-form-item>
        <el-form-item label="最后修改时间" prop="lastUpdateTime">
          <el-date-picker clearable v-model="form.lastUpdateTime" type="date" value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择最后修改时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="计划完成桩数" prop="planPiles">
          <el-input v-model="form.planPiles" placeholder="请输入计划完成桩数" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 详情弹窗 -->
    <el-dialog :visible.sync="detailOpen" width="900px" :show-close="true" append-to-body class="project-detail-dialog">
      <div class="project-detail-title">项目详情信息</div>

      <div class="project-section-title">基本信息</div>
      <div class="project-row-flex">
        <div class="project-col-flex">
          <table class="project-detail-table">
            <tr>
              <th class="left-align">项目编码</th>
              <td class="value">{{ detailData && detailData.projectNo }}</td>
            </tr>
            <tr>
              <th class="left-align">项目名称</th>
              <td class="value">{{ detailData && detailData.projectName }}</td>
            </tr>
            <tr>
              <th class="left-align">项目地址</th>
              <td class="value">{{ detailData && detailData.projectAddress }}</td>
            </tr>
            <tr>
              <th class="left-align">项目经理</th>
              <td class="value">{{ detailData && detailData.projectManager }}</td>
            </tr>
            <tr>
              <th class="left-align">项目类型</th>
              <td class="value">{{ detailData && detailData.projectType }}</td>
            </tr>
            <tr>
              <th class="left-align">工程类型</th>
              <td class="value">{{ detailData && detailData.engineeringType }}</td>
            </tr>
            <tr>
              <th class="left-align">运行状态</th>
              <td class="value">{{ detailData && detailData.operationStatus }}</td>
            </tr>
            <tr>
              <th class="left-align">开工时间</th>
              <td class="value">{{ detailData && detailData.startTime ? parseTime(detailData.startTime) : '—' }}</td>
            </tr>
          </table>
        </div>
        <div class="project-col-flex">
          <table class="project-detail-table">
            <tr>
              <th class="left-align">项目产值(万元)</th>
              <td class="value">{{ detailData && detailData.outputValue }}</td>
            </tr>
            <tr>
              <th class="left-align">省份名称</th>
              <td class="value">{{ detailData && detailData.provinceName }}</td>
            </tr>
            <tr>
              <th class="left-align">城市名称</th>
              <td class="value">{{ detailData && detailData.cityName }}</td>
            </tr>
            <tr>
              <th class="left-align">区名称</th>
              <td class="value">{{ detailData && detailData.regionName }}</td>
            </tr>
            <tr>
              <th class="left-align">设备序列号</th>
              <td class="value">{{ detailData && detailData.deviceSerial }}</td>
            </tr>
            <tr>
              <th class="left-align">经度</th>
              <td class="value">{{ detailData && detailData.longitude }}</td>
            </tr>
            <tr>
              <th class="left-align">纬度</th>
              <td class="value">{{ detailData && detailData.latitude }}</td>
            </tr>
            <tr>
              <th class="left-align">计划完成桩数</th>
              <td class="value">{{ detailData && detailData.planPiles }}</td>
            </tr>
          </table>
        </div>
      </div>

      <div class="project-section-title">工程信息</div>
      <table class="project-detail-table">
        <tr>
          <th class="center-bg">工程性质</th>
          <td class="value">{{ detailData && detailData.engineeringNature }}</td>
          <th class="center-bg">地层信息</th>
          <td class="value">{{ detailData && detailData.strataInformation }}</td>
        </tr>
        <tr>
          <th class="center-bg">地下水</th>
          <td class="value">{{ detailData && detailData.groundwater }}</td>
          <th class="center-bg">地形、地貌特征</th>
          <td class="value">{{ detailData && detailData.topographyFeature }}</td>
        </tr>
        <tr>
          <th class="center-bg">地震信息</th>
          <td class="value">{{ detailData && detailData.seismicInformation }}</td>
          <th class="center-bg">不良地质</th>
          <td class="value">{{ detailData && detailData.geologicalHazards }}</td>
        </tr>
        <tr>
          <th class="center-bg">腐蚀性评价</th>
          <td class="value">{{ detailData && detailData.corrosionEvaluation }}</td>
          <th class="center-bg">备注</th>
          <td class="value">{{ detailData && detailData.remarks }}</td>
        </tr>
      </table>

      <!-- <div class="project-section-title">系统信息</div>
      <table class="project-detail-table">
        <tr>
          <th class="center-bg">创建人</th>
          <td class="value">{{ detailData && detailData.creatorName }}</td>
          <th class="center-bg">创建时间</th>
          <td class="value">{{ detailData && detailData.createTime ? parseTime(detailData.createTime) : '—' }}</td>
        </tr>
        <tr>
          <th class="center-bg">最后修改人</th>
          <td class="value">{{ detailData && detailData.lastUpdaterName }}</td>
          <th class="center-bg">最后修改时间</th>
          <td class="value">{{ detailData && detailData.lastUpdateTime ? parseTime(detailData.lastUpdateTime) : '—' }}
          </td>
        </tr>
      </table> -->

      <span slot="footer" class="dialog-footer">
        <el-button @click="detailOpen = false" type="primary" plain>关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { listProject, getProject, delProject, addProject, updateProject } from "@/api/pile/project";

export default {
  name: "Project",
  data() {
    return {
      // 根路径
      baseURL: process.env.VUE_APP_BASE_API,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 项目表格数据
      projectList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        projectNo: null,
        projectName: null,
        addressId: null,
        projectAddress: null,
        projectManager: null,
        projectType: null,
        engineeringType: null,
        operationStatus: null,
        remarks: null,
        engineeringNature: null,
        strataInformation: null,
        groundwater: null,
        topographyFeature: null,
        seismicInformation: null,
        geologicalHazards: null,
        corrosionEvaluation: null,
        startTime: null,
        outputValue: null,
        provinceId: null,
        provinceName: null,
        cityName: null,
        regionName: null,
        deviceSerial: null,
        longitude: null,
        latitude: null,
        creatorId: null,
        creatorName: null,
        lastUpdaterId: null,
        lastUpdaterName: null,
        lastUpdateTime: null,
        planPiles: null
      },
      // 表单参数
      form: {},
      // 详情弹窗相关
      detailOpen: false,
      detailData: null,
      // 表单校验
      rules: {
        id: [
          { required: true, message: "主键不能为空", trigger: "blur" }
        ],
        projectNo: [
          { required: true, message: "项目编码不能为空", trigger: "blur" }
        ],
        projectName: [
          { required: true, message: "项目名称不能为空", trigger: "blur" }
        ],
        addressId: [
          { required: true, message: "地理id不能为空", trigger: "blur" }
        ],
        projectAddress: [
          { required: true, message: "项目地址不能为空", trigger: "blur" }
        ],
        projectManager: [
          { required: true, message: "项目经理不能为空", trigger: "blur" }
        ],
        projectType: [
          { required: true, message: "项目类型不能为空", trigger: "change" }
        ],
        engineeringType: [
          { required: true, message: "工程类型不能为空", trigger: "change" }
        ],
        operationStatus: [
          { required: true, message: "运行状态不能为空", trigger: "blur" }
        ],
        remarks: [
          { required: true, message: "备注不能为空", trigger: "blur" }
        ],
        engineeringNature: [
          { required: true, message: "工程性质不能为空", trigger: "blur" }
        ],
        strataInformation: [
          { required: true, message: "地层信息不能为空", trigger: "blur" }
        ],
        groundwater: [
          { required: true, message: "地下水不能为空", trigger: "blur" }
        ],
        topographyFeature: [
          { required: true, message: "地形、地貌特征不能为空", trigger: "blur" }
        ],
        seismicInformation: [
          { required: true, message: "地震信息不能为空", trigger: "blur" }
        ],
        geologicalHazards: [
          { required: true, message: "不良地质不能为空", trigger: "blur" }
        ],
        corrosionEvaluation: [
          { required: true, message: "腐蚀性评价不能为空", trigger: "blur" }
        ],
        startTime: [
          { required: true, message: "开工时间不能为空", trigger: "blur" }
        ],
        outputValue: [
          { required: true, message: "项目产值(万元)不能为空", trigger: "blur" }
        ],
        provinceId: [
          { required: true, message: "省份id不能为空", trigger: "blur" }
        ],
        provinceName: [
          { required: true, message: "省份名称不能为空", trigger: "blur" }
        ],
        cityName: [
          { required: true, message: "城市名称不能为空", trigger: "blur" }
        ],
        regionName: [
          { required: true, message: "区名称不能为空", trigger: "blur" }
        ],
        deviceSerial: [
          { required: true, message: "设备序列号不能为空", trigger: "blur" }
        ],
        longitude: [
          { required: true, message: "经度不能为空", trigger: "blur" }
        ],
        latitude: [
          { required: true, message: "纬度不能为空", trigger: "blur" }
        ],
        creatorId: [
          { required: true, message: "创建人id不能为空", trigger: "blur" }
        ],
        creatorName: [
          { required: true, message: "创建人姓名不能为空", trigger: "blur" }
        ],
        lastUpdaterId: [
          { required: true, message: "最后修改人id不能为空", trigger: "blur" }
        ],
        lastUpdaterName: [
          { required: true, message: "最后修改人姓名不能为空", trigger: "blur" }
        ],
        lastUpdateTime: [
          { required: true, message: "最后修改时间不能为空", trigger: "blur" }
        ],
        planPiles: [
          { required: true, message: "计划完成桩数不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询项目列表 */
    getList() {
      this.loading = true;
      listProject(this.queryParams).then(response => {
        this.projectList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        projectNo: null,
        projectName: null,
        addressId: null,
        projectAddress: null,
        projectManager: null,
        projectType: null,
        engineeringType: null,
        operationStatus: "0",
        remarks: null,
        engineeringNature: null,
        strataInformation: null,
        groundwater: null,
        topographyFeature: null,
        seismicInformation: null,
        geologicalHazards: null,
        corrosionEvaluation: null,
        startTime: null,
        outputValue: null,
        provinceId: null,
        provinceName: null,
        cityName: null,
        regionName: null,
        deviceSerial: null,
        longitude: null,
        latitude: null,
        creatorId: null,
        creatorName: null,
        lastUpdaterId: null,
        lastUpdaterName: null,
        lastUpdateTime: null,
        planPiles: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加项目";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getProject(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改项目";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateProject(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addProject(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除项目编号为"' + ids + '"的数据项？').then(function () {
        return delProject(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('pile/project/export', {
        ...this.queryParams
      }, `project_${new Date().getTime()}.xlsx`)
    },
    /** 获取项目类型样式类名 */
    getProjectTypeClass(projectType) {
      const typeMap = {
        '房建': 'project-type construction',
        '市政': 'project-type municipal',
        '水利': 'project-type water-conservancy'
      };
      return typeMap[projectType] || 'project-type';
    },
    /** 获取运行状态样式类名 */
    getOperationStatusClass(operationStatus) {
      const statusMap = {
        '进行中': 'status in-progress',
        '未启动': 'status not-started',
        '停滞': 'status stagnant',
        '已完工': 'status completed'
      };
      return statusMap[operationStatus] || 'status';
    },
    /** 详情按钮操作 */
    handleDetail(row) {
      const id = row && row.id ? row.id : this.ids.length === 1 ? this.ids[0] : null;
      if (!id) {
        this.$modal.msgError("请选择一条数据");
        return;
      }
      getProject(id).then((response) => {
        this.detailData = response.data;
        this.detailOpen = true;
      });
    }
  }
};
</script>

<style scoped>
.project-name {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif;
  font-weight: 500;
  color: #1f2937;
}

.project-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border: 1px solid transparent;
  background: linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(135deg, #e5e7eb, #e5e7eb) border-box;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.project-type::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.project-type.construction {
  background: linear-gradient(#f0f9ff, #f0f9ff) padding-box,
    linear-gradient(135deg, #3b82f6, #1d4ed8) border-box;
  color: #1e40af;
}

.project-type.municipal {
  background: linear-gradient(#f0fdf4, #f0fdf4) padding-box,
    linear-gradient(135deg, #10b981, #059669) border-box;
  color: #047857;
}

.project-type.water-conservancy {
  background: linear-gradient(#f0f9ff, #f0f9ff) padding-box,
    linear-gradient(135deg, #06b6d4, #0891b2) border-box;
  color: #0e7490;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border: 1px solid transparent;
  background: linear-gradient(#ffffff, #ffffff) padding-box,
    linear-gradient(135deg, #e5e7eb, #e5e7eb) border-box;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s infinite;
}

.status.in-progress {
  background: linear-gradient(#fef3c7, #fef3c7) padding-box,
    linear-gradient(135deg, #f59e0b, #d97706) border-box;
  color: #b45309;
}

.status.not-started {
  background: linear-gradient(#f8fafc, #f8fafc) padding-box,
    linear-gradient(135deg, #94a3b8, #64748b) border-box;
  color: #475569;
}

.status.stagnant {
  background: linear-gradient(#fef2f2, #fef2f2) padding-box,
    linear-gradient(135deg, #ef4444, #dc2626) border-box;
  color: #b91c1c;
}

.status.completed {
  background: linear-gradient(#f0fdf4, #f0fdf4) padding-box,
    linear-gradient(135deg, #10b981, #059669) border-box;
  color: #047857;
}

.status.not-started::before,
.status.stagnant::before,
.status.completed::before {
  animation: none;
}

.status.not-started::before {
  background: #64748b;
}

.status.stagnant::before {
  background: #dc2626;
}

.status.completed::before {
  background: #10b981;
}

@keyframes pulse {
  0% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.start-time {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 12px;
  color: #0f172a;
  font-weight: 600;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  line-height: 1.4;
  transition: all 0.15s ease;
}

.start-time:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.empty-time {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 12px;
  color: #64748b;
  font-style: normal;
  font-weight: 600;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  line-height: 1.4;
  transition: all 0.15s ease;
}

.empty-time:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

/* 详情弹窗样式 */
.project-detail-dialog .el-dialog__body {
  background: #f4f6fb;
  padding: 0;
}

.project-detail-title {
  font-size: 22px;
  font-weight: bold;
  color: #2d3a4b;
  margin-bottom: 16px;
  text-align: center;
  letter-spacing: 2px;
}

.project-section-title {
  font-size: 18px;
  color: #4a90e2;
  font-weight: bold;
  margin: 32px 0 16px 0;
  border-left: 4px solid #4a90e2;
  padding-left: 12px;
  letter-spacing: 1px;
}

.project-row-flex {
  display: flex;
  gap: 32px;
  margin-bottom: 12px;
}

.project-col-flex {
  flex: 1;
}

.project-detail-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: none;
}

.project-detail-table th,
.project-detail-table td {
  padding: 10px 8px;
  font-size: 16px;
  border-bottom: 1px solid #f0f0f0;
}

.project-detail-table th {
  width: 120px;
  color: #6b7a90;
  background: none;
  font-weight: normal;
  text-align: right;
  vertical-align: top;
  padding-right: 12px;
}

.project-detail-table td.value {
  color: #222;
  text-align: left;
  font-weight: 500;
}

.project-detail-table tr:last-child td,
.project-detail-table tr:last-child th {
  border-bottom: none;
}

.project-detail-table th.left-align {
  text-align: center;
  padding-left: 0;
  padding-right: 0;
  background: #f7fafd;
}

.project-detail-table th.center-bg {
  text-align: center;
  vertical-align: middle;
  background: #f7fafd;
  width: 180px;
}

@media (max-width: 900px) {
  .project-row-flex {
    flex-direction: column;
    gap: 0;
  }
}

@media (max-width: 600px) {
  .project-detail-title {
    font-size: 20px;
  }

  .project-section-title {
    font-size: 15px;
    padding-left: 8px;
  }

  .project-detail-table th,
  .project-detail-table td {
    font-size: 13px;
    padding: 7px 4px;
  }
}
</style>
